package com.woniu.controller;/*
 *
 * @author   米雷
 * @Description
 * @Date:create in 12:23 2020-03-24
 *
 * */

import com.woniu.dto.HomeDetail;
import com.woniu.dto.MapDto;
import com.woniu.pojo.Home;
import com.woniu.service.HomeService;
import com.woniu.userLog.LogPoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "房屋相关操作")
@RequestMapping("/home")
@Controller
@CrossOrigin(allowCredentials="true",maxAge = 3600)
public class HomeController {

    @Autowired
    HomeService homeService;


    /*
     *  @auth:米雷
     *  修改用户的房屋，
     *
     **/
    @ApiOperation(value = "修改房屋")
    @PostMapping("/update")
    @ResponseBody
    @LogPoint("用户修改房屋信息")
    public String updateHome(String address,Long id)
    {
        String result = homeService.updateHome(address,id);
        return result;
    }

    /*
     *  @auth:米雷
     *  添加用户的房屋
     *
     **/
    @ApiOperation(value = "添加房屋")
    @PutMapping("/add")
    @ResponseBody
    @LogPoint("用户添加房屋")
    public String addHome(Home home)
    {
        String result = homeService.addHome(home);
        return result;
    }

    /*
     *  @auth:米雷
     *  删除用户的房屋
     *
     **/
    @ApiOperation(value = "删除房屋")
    @DeleteMapping("/delete")
    @ResponseBody
    @LogPoint("用户删除房屋")
    public String deleteHome(Long id)
    {
        String result = homeService.deleteHome(id);
        return result;
    }

    /*
     *  @auth:米雷
     *  查询用户的房屋
     *
     **/
    @GetMapping("/get")
    @ResponseBody
    @ApiOperation(value = "查看房屋")
    @LogPoint("用户查看房屋")
    public HomeDetail getHome(Long id)
    {
        HomeDetail home=homeService.getHome(id);
        System.out.println(home);
        return home;
    }

    @PostMapping("/byMap")
    @ResponseBody
    @ApiOperation(value = "修改房屋")
    @LogPoint("用户查看房屋")
    public void returnMap(MapDto ss) {
       String address= ss.getHotelAddress();
        System.out.println(address+" 00000000000000000000000000");

    }

}
